import React, { Component, Fragment } from 'react';
import { connect } from 'dva';
import { Button, Card, Divider } from 'antd';
import DescriptionList from 'components/DescriptionList';
import PageHeaderLayout from '../../layouts/PageHeaderLayout';

const { Description } = DescriptionList;
const ButtonGroup = Button.Group;

@connect(({ sysNotice, loading }) => ({
  sysNotice,
  loading: loading.effects['sysNotice/loadDomain'],
}))
export default class SysNoticeProfile extends Component {
  componentDidMount() {
    const {
      dispatch,
      match: { params },
    } = this.props;
    dispatch({
      type: 'sysNotice/loadDomain',
      payload: params.pid,
    });
  }

  goback = () => {
    history.back();
  };

  render() {
    const {
      sysNotice: { domain },
    } = this.props;
    const action = (
      <Fragment>
        <ButtonGroup>
          <Button icon="rollback" onClick={this.goback}>
            返回
          </Button>
        </ButtonGroup>
      </Fragment>
    );

    return (
      <PageHeaderLayout title="通知管理" action={action}>
        <Card bordered={false}>
          <DescriptionList size="large" title="基础信息" style={{ marginBottom: 32 }}>
            <Description term="通知id">{domain.nid}</Description>
            <Description term="通知类型（notice.type）">{domain.ntypeName}</Description>
            <Description term="通知标题">{domain.title}</Description>
            <Description term="通知内容">{domain.content}</Description>
            <Description term="通知banner图">{domain.picBanner}</Description>
            <Description term="创建人">{domain.createUser}</Description>
            <Description term="创建时间">{domain.createTime}</Description>
            <Description term="更新人员">{domain.updateUser}</Description>
            <Description term="更新时间">{domain.updateTime}</Description>
            <Description term="通知状态（notice.status）">{domain.nstatusName}</Description>
          </DescriptionList>
          <Divider style={{ marginBottom: 32 }} />
        </Card>
      </PageHeaderLayout>
    );
  }
}
